﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using SongSharp.Domain.Data;
using System.Reflection;

namespace SongSharp.Domain.Objects
{
    [Serializable()]
    public class TrackStatistic
    {
        private static DataManager DataContext = DataManager.Instance;

        public string Uid { get; set; }
        public List<EnvironmentCapture> EnvironmentCaptures { get; set; }
        public int PlayedExplicitCount { get; set; }
        public int PlayedSuggestedCount { get; set; }
        public int EnqueuedExplicitCount { get; set; }
        public int SkippedCount { get; set; }
        public DateTime DateAdded { get; set; }
        public double VaryVogueValue { get; set; }
        public double WeightedRandom { get; set; }

        public EnvironmentCapture GetLastAction(TrackHandlingType handling)
        {
            return (from c in this.EnvironmentCaptures
                    where c.HandlingType == handling
                    orderby c.Date descending
                    select c).FirstOrDefault();
        }

        public void PerformEnvironmentSnapShot(TrackHandlingType handling)
        {
            EnvironmentCapture e = new EnvironmentCapture();
            e.Date = DateTime.Now;
            e.HandlingType = handling;

            if (this.EnvironmentCaptures == null)
                this.EnvironmentCaptures = new List<EnvironmentCapture>();
            this.EnvironmentCaptures.Add(e);
        }
    }
}
